#-*-encoding:utf-8-*-
from bsite import Bsite
import random
import os
import csv
ver="0.01(Alpha)"
def Initialize():
    global ver
    print("欢迎使用哔哩哔哩评论抽奖工具（非官方、已开原）")
    print("当前版本为"+ver)
    if os.path.exists("comments.csv") and os.path.isfile("comments.csv"):
        os.remove("comments.csv")
    Bvid=input("请输入要抽奖的视频Bv号:（例如BV1sV411o73v）")
    return Bvid
def GetComments(Bvid):
    cookies = {"cookie": 你的cookie}
    bs = Bsite(cookies=cookies)
    aid=bs.bvid2aid(bvid=Bvid)
    bs.comments(aid=aid, csvfpath='comments.csv')
def ReadUserName():
    UserName=[]
    FUN=[]
    with open("comments.csv", "r",encoding="utf-8") as f:
        reader=csv.reader(f)
        for i in reader:
            UserName.append(i[9])
        UserName.remove("uname")
        for i in UserName:
            if i not in FUN:
                FUN.append(i)
    return FUN
def Randomchoice(UserName):
    Result=[]
    Count=int(input("请输入本次中奖人数："))
    for i in range(Count):
        Result.append(random.choice(UserName))
    print("本次抽奖中奖的人有：",end=" ")
    for i in Result:
        print(i,end=" ")
GetComments(Initialize())
Randomchoice(ReadUserName())
